package com.blank.shop.ssr.service.impl;

import com.blank.shop.ssr.service.ArticleService;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;

/**
 * <br/>Date 2021/9/6
 * <br/>Time 10:56:37
 *
 * @author _blank
 */
@Service
public class ArticleServiceImpl implements ArticleService {
    private final ValueOperations<Object, Object> forValue;

    public ArticleServiceImpl(RedisTemplate<Object, Object> redisTemplate) {
        this.forValue = redisTemplate.opsForValue();
    }

    @Override
    public String likeArticle(String articleId) {
        final Long likeNumber = this.forValue.increment(articleId);
        return "文章编号: " + articleId + ",喜欢数: " + likeNumber;
    }
}
